package net.techwatch.gwt.mvp.client;

import net.techwatch.gwt.mvp.client.event.SubmitEvent;
import net.techwatch.gwt.mvp.client.event.SubmitEventHandler;
import net.techwatch.gwt.mvp.client.gin.AppGinjector;
import net.techwatch.gwt.mvp.client.service.GreetingService;
import net.techwatch.gwt.mvp.client.service.GreetingServiceAsync;
import net.techwatch.gwt.mvp.client.view.MessageDisplayer;
import net.techwatch.gwt.mvp.client.view.MessageDisplayerImpl;
import net.techwatch.gwt.mvp.client.view.MessageDisplayerWidget;
import net.techwatch.gwt.mvp.client.view.MessageForm;
import net.techwatch.gwt.mvp.client.view.MessageFormImpl;
import net.techwatch.gwt.mvp.client.view.MessageFormWidget;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.ui.RootPanel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Gwt_mvp implements EntryPoint {
	/**
	 * The message displayed to the user when the server cannot be reached or
	 * returns an error.
	 */
	private static final String SERVER_ERROR = "An error occurred while "
			+ "attempting to contact the server. Please check your network "
			+ "connection and try again.";
	
	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		final AppGinjector injector = GWT.create(AppGinjector.class);
		MessageForm editor = injector.getMessageForm();
		MessageDisplayer displayer = injector.getMessageDisplayer();
		HandlerManager eventBus = injector.getEventBus();
		
		
		eventBus.addHandler(SubmitEvent.getType(), new SubmitEventHandler(displayer));
		
		RootPanel.get().add(editor.getView().getWidget());
	}
}
